package com.mzx.javase.duotai;

/**
 * @Description:继承中类的多态
 * @Date: 2021/11/19 15:25
 * @Author: MarKing
 */
class Cat extends Animal {
    private String color;

    @Override
    public void eat() {
        System.out.println(super.getName()+"猫正在吃东西");
    }

    public void work() {
        System.out.println(super.getName()+"正在抓老鼠");
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
}

class Dog extends Animal {
    private String color;

    @Override
    public void eat() {
        System.out.println(super.getName()+"狗正在吃东西");
    }

    public void work() {
        System.out.println(super.getName()+"狗正在看家");
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
}

public class Animal {
    private String name;
    private int age;

    public void eat() {
        System.out.println("动物正在吃的东西");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
